<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org"
xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
	<meta charset="utf-8">
	<title>日志管理</title>
	<meta name="renderer" content="webkit">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<meta name="apple-mobile-web-app-status-bar-style" content="black">
	<meta name="apple-mobile-web-app-capable" content="yes">
	<meta name="format-detection" content="telephone=no">
	<link rel="stylesheet" href="/resources/layui/css/layui.css" media="all" />
	<link rel="stylesheet" href="/resources/css/public.css" media="all" />
</head>
<body class="childrenBody">
	<!-- 查询开始 -->
	<form class="layui-form"  id="searchFrm">
	  <div class="layui-form-item">
	    <div class="layui-inline">
	      <label class="layui-form-label">登陆用户</label>
	      <div class="layui-input-inline">
	        <input type="text" name="loginname"  autocomplete="off" class="layui-input">
	      </div>
	    </div>
	    <div class="layui-inline">
	      <label class="layui-form-label">登陆IP</label>
	      <div class="layui-input-inline">
	        <input type="text" name="loginip"  autocomplete="off" class="layui-input">
	      </div>
	    </div>
	    <div class="layui-inline">
	      <label class="layui-form-label">开始时间</label>
	      <div class="layui-input-inline">
	        <input type="text" name="startDate" id="startDate"  autocomplete="off" class="layui-input">
	      </div>
	    </div>
	    <div class="layui-inline">
	      <label class="layui-form-label">结束时间</label>
	      <div class="layui-input-inline">
	        <input type="text" name="endDate"  id="endDate" autocomplete="off" class="layui-input">
	      </div>
	    </div>
	  </div>
	  <div class="layui-form-item" style="text-align: center;">
	    <div class="layui-input-block">
	      <button type="button" class="layui-btn" id="doSearch">查询</button>
	      <button type="reset" class="layui-btn layui-btn-primary">重置</button>
	    </div>
	  </div>
	</form>
	<!-- 查询结束 -->
	<!-- 数据表格开始 -->
	<table class="layui-hide" id="logLoginList" lay-filter="logLoginList"></table>
	<div id="toolBar" style="display: none;" lay-filter="toolBar">
		<button type="button"   class="layui-btn  layui-btn-sm layui-btn-danger"  lay-event="delete">删除</button>
	</div>
	<!-- 数据表格结束 -->
	<script src="/resources/layui/layui.js" charset="utf-8"></script>
	
	<script type="text/javascript">
		layui.use([ 'element', 'layer', 'jquery', 'form', 'table','laydate' ],
				function() {
					var element = layui.element;
					var layer = layui.layer;
					var $ = layui.jquery;
					var laydate = layui.laydate;
					var form = layui.form;
					var table = layui.table;
					var laydate=layui.laydate;
					//渲染时间选择器
					laydate.render({
						elem:'#startDate',
						type:'datetime'
					})
					laydate.render({
						elem:'#endDate',
						type:'datetime'
					})
					var tableIns=table.render({
					    elem: '#logLoginList'  //指渲染的目标  
					    ,url:'/logLogin/loadAllLogLogin'//请求地址
					    ,cellMinWidth: 80 //全局定义常规单元格的最小宽度
					    ,height:'full-200'//设置高度    
					 	,page:true//开启分页
					 	,toolbar:true//设置显示工具条并设置表头左边的工具类
					    ,cols: [ [
					      {field:'id',  title: 'ID', sort: true,align:"center"}
					      ,{field:'loginname',  title: '登陆名',align:"center"}
					      ,{field:'loginip',  title: '登陆IP',align:"center"}
					      ,{field:'logintime',  title: '登陆时间',align:"center"}
					      ,{width:200, title: '操作', toolbar:"#toolBar",align:"center",fixed:"right"}
					    ] ]
					  });
					  //查询
					  $("#doSearch").click(function(){
						  var params=$("#searchFrm").serialize();
						  tableIns.reload({url: '/logLogin/loadAllLogLogin?'+params});
					  });
					//监听行工具栏的事件
					  table.on('tool(logLoginList)', function(obj){
						  var data = obj.data; //获得当前行数据
						    switch(obj.event){
						      case 'delete':
						    	  layer.confirm('确定此日志？',{icon:3, title:'提示信息'},function(index){
						                 $.post("/logLogin/deleteLogLogin",{
						                     id : data.id  //将需要删除的id作为参数传入
						                 },function(data){
						                	tableIns.reload();
						                	layer.msg(data.msg);
						                    layer.close(index);
						                 })
						            });
						      break;
						    };
						  });
				});
	</script>
</body>
</html>